<!--登录页面  -->
<template>
  <div class="login-card">
    <h3 class="login-title">Log In</h3>
    <p class="login-desc">Hello, welcome to COVID-19 Vaccine fund</p>
    <div class="login-form">
      <div class="form-item">
        <p>Account number</p>
        <input
          type="text"
          v-model="loginForm.phone"
          placeholder=" Please enter the phone number"
        />
      </div>

      <div class="form-item">
        <p>Password</p>
        <input
          type="password"
          v-model="loginForm.password"
          placeholder="Please enter a password"
        />
      </div>
      <button @click="confirmSubmit">Log In</button>
    </div>
    <p class="forget-pass" @click="$router.push('/forgetPassword')">
      Forgot password
    </p>
    <p class="to-sign">
      No account yet？<span @click="$router.push('/register')">Sign up</span>
    </p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loginForm: {
        password: "",
        phone: "",
      },
    };
  },
  methods: {
    confirmSubmit() {
      if (this.loginForm["phone"] == "") {
        this.$toast("Please enter the phone number");
        return;
      }
      if (this.loginForm["password"] == "") {
        this.$toast("Please enter the password");
        return;
      }
      let data = {
        name: this.loginForm["phone"],
        password: this.loginForm["password"],
      };
      this.login(data);
    },
    login(data) {
      this.$store.dispatch("login", data).then((res) => {
        res == true &&
          this.$toast("Login successed") &&
          this.$router.replace("/market");
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.login-card {
  height: 100%;
  min-height: 100vh;
  padding: 0 38px;
  background-color: #fff;
  background: url("../../assets/imgs/login_bg.png");
  background-size: contain;
  .login-title {
    padding: 70px 0 0 0;
    font-weight: bold;
    font-size: 35px;
    line-height: 35px;
    color: #ffffff;
  }
  .login-desc {
    margin: 12px 0 0 0;
    font-size: 12px;
    color: #ffffff;
  }
  .login-form {
    margin: 77px 0 0 0;
    font-size: 15px;
    color: #fff;
    .form-item {
      margin: 0 0 30px 0;
    }
    .form-item p {
      margin: 0 0 12px 0;
    }
    input {
      width: 300px;
      height: 50px;
      border: none;
      background: rgba(186, 202, 255, 0.27);
      font-size: 12px;
      padding: 0 10px;
      border-radius: 5px;
    }
    input::-webkit-input-placeholder {
      color: #fff;
    }
    button {
      width: 300px;
      height: 50px;
      background: #4a67f5;
      box-shadow: 0px 2px 6px rgba(45, 88, 234, 0.5);
      opacity: 1;
      border-radius: 25px;
      border: none;
    }
  }
  .forget-pass {
    text-align: center;
    margin: 30px 0 0 0;
    font-size: 12px;
    color: #fff;
  }
  .to-sign {
    margin: 96px 0 0 0;
    text-align: center;
    color: #fff;
    span {
      font-size: 15px;
      color: #2c57e7;
    }
  }
}
</style>